﻿@model GPS.ENTITYS.ViewModelSDONVIHC
@using PagedList.Mvc;
@using GPS.Helpers;
@{
    ViewBag.Title = "Đơn Vị Hành Chính";
}

<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
<script src="~/Scripts/jquery.maskedinput.js"></script>
<script src="~/Scripts/datepicker.js"></script>

<script>
    @*$("#dDVHC_TP_DLL").change(function () {
        $.ajax({
            url: '@Url.Action("getQuan_Huyen", "GPS_DonViHanhChinh")',
            type: 'post',
            data: {
                ma_DVGT: $('#dDVHC_TP_DLL').val()
            }
        }).done(function (response) {
            // update district by province
            var a = '<option value></option>' + response;   // defaut value
            $("#dDVHC_QH_DLL").html(a);

            // reset ward
            var b = '<option value></option>'
            $('#dDVHC_QH_DLL').html(b);

            var b = '<option value></option>'
            $('#dDVHC_XP_DLL').html(b);
        });
    });*@

    $("#dDVHC_TP_DLL").change(function () {
        $.ajax({
            url: '@Url.Action("getQuan_Huyen", "GPS_DonViHanhChinh")',
            type: 'post',
            data: {
                ma_TP: $('#dDVHC_TP_DLL').val()
            }
        }).done(function (response) {
            // update district by province
            var a = '<option value></option>' + response;   // defaut value
            $("#dDVHC_QH_DLL").html(a);

            // reset ward
            var b = '<option value></option>'
            $('#dDVHC_QH_DLL').html(b);

            var b = '<option value></option>'
            $('#dDVHC_XP_DLL').html(b);
        });
    });
</script>

<div class="container fdb-div-content fdb-div-corner-all">
    <h3 class="text-center fdb-title-search-form">danh mục Đơn Vị Hành Chính</h3>
    <div class="row">
        @using (Html.BeginForm("Index", "GPS_DonViHanhChinh", FormMethod.Get, new { id = "demoForm", name = "demoForm" }))
        {
            <div class="list-group">
                <fieldset class="fs_body">
                    <legend class="head_title">Điều Kiện Tìm Kiếm</legend>
                    <div class="criteria_search">
                        <div class="row margin-top-05">
                            <div class="col-md-2 control-label">
                                Loại Đơn Vị
                            </div>
                            <div class="col-md-4">
                                @Html.DropDownListFor(model => model.dDVHC_LOAI, (SelectList)ViewBag.LstLoaiDonVi, " -- Lựa Chọn -- ", new { @class = "form-control", @id = "dDVHC_LOAI_DLL" })
                            </div>

                            <div class="col-md-2 control-label">
                                    Tỉnh/Thành Phố
                                </div>
                                <div class="col-md-4">
                                    @Html.DropDownListFor(model => model.dDVHC_TEN, (SelectList)ViewBag.LstTinh_ThanhPho, " -- Lựa Chọn -- ", new { @class = "form-control", @id = "dDVHC_TP_DLL" })
                                </div>
                        </div>

                        <div class="row margin-top-05">
                            <div class="col-md-2 control-label">
                                    Quận/Huyện
                                </div>
                                <div class="col-md-4">
                                    @Html.DropDownListFor(model => model.dDVHC_TEN, (SelectList)ViewBag.LstQuan_Huyen, " -- Lựa Chọn -- ", new { @class = "form-control", @id = "dDVHC_QH_DLL" })
                                </div>
                                <div class="col-md-2 control-label">
                                    Xã/Phường
                                </div>
                                <div class="col-md-4">
                                    @Html.DropDownListFor(model => model.dDVHC_TEN, (SelectList)ViewBag.LstXa_Phuong, " -- Lựa Chọn -- ", new { @class = "form-control", @id = "dDVHC_XP_DLL" })
                                </div>
                        </div>

                        <div class="row margin-top-05">
                            <div class="col-md-2 control-label">
                                Trạng Thái
                            </div>
                            <div class="col-md-4">
                                @Html.DropDownListFor(model => model.dDVHC_ACTIVE, new List<SelectListItem>
                                {
                                    new SelectListItem() {Text = "--Lựa Chọn--", Value=""},
                                    new SelectListItem() {Text = "Không Hiệu Lực", Value="0"},
                                    new SelectListItem() {Text = "Hiệu Lực", Value="1"}
                                }, new { @class = "form-control" })
                            </div>
                        </div>
                    </div>
                    <div class="row margin-top-05 btn_search">
                        <button type="submit" class="btn btn-primary btn-sm">
                            <span class="glyphicon glyphicon-search"></span> Tìm kiếm
                        </button>
                        <div style="float: right; margin:0 2px;">
                            @Html.NoEncodeActionLink("<span class='glyphicon glyphicon-plus'></span> Thêm mới", "Thêm mới", "Create", "GPS_DonViHanhChinh", null, htmlAttributes: new { @class = "btn btn-primary btn-sm" })
                        </div>
                        <div style="float: right; margin:0 2px;">
                            @Html.NoEncodeActionLink("<i class='fa fa-file-excel-o'></i> Import XML", "Import XML", "ImportXML", "GPS_DonViHanhChinh", null, htmlAttributes: new { @class = "btn btn-primary btn-sm" })


                        </div>
                    </div>
                </fieldset>
            </div>
        }
        <br />
        <div class="row">
            <fieldset class="fs_body">
                <legend class="head_title">Kết quả tìm kiếm</legend>
                <div class="divbtnFielset">
                    <div style="float: right;">
                        <label id="lblMessageTotal" style="color:blue; font-weight:bold">Tổng số bản ghi: @ViewBag.TotalRow</label>
                    </div>
                </div>
                <div style="clear:both; padding: 5px 0;">
                    <table class="table table-striped table-hover table-bordered table-condensed">
                        <tr>
                            <th>
                                Mã đơn vị quản lý
                            </th>
                            <th>
                                Tên đơn vị quản lý
                            </th>
                            <th>
                                Mã đơn vị
                            </th>
                            <th>
                                Tên đơn vị
                            </th>
                            <th>
                                Loại đơn vị
                            </th>
                            <th>
                                Trạng thái
                            </th>
                            <th>
                                Thao tác
                            </th>
                        </tr>
                        @{
                            if (Model.SearchResults != null)
                            {
                                foreach (var item in Model.SearchResults)
                                {
                                    <tr>
                                        <td>
                                            @Html.DisplayFor(modelItem => item.DVHC_MAQL)
                                        </td>
                                        <td>
                                            @Model.lstDonViHanhChinh.Where(x => x.DVHC_MA == item.DVHC_MAQL).Select(x => x.DVHC_TEN).FirstOrDefault().ToString()
                                        </td>
                                        <td>
                                            @Html.DisplayFor(modelItem => item.DVHC_MA)
                                        </td>
                                        <td>
                                            @Html.DisplayFor(modelItem => item.DVHC_TEN)
                                        </td>
                                        <td>
                                            @Html.DisplayFor(modelItem => item.DVHC_LOAI)
                                        </td>
                                        <td>
                                            @{
                                    if (item.DVHC_ACTIVE == "1")
                                    {
                                        @Html.Label("Hiệu Lực")
                                    }
                                    else
                                    {
                                        @Html.Label("không Hiệu Lực")
                                    }
                                            }
                                        </td>
                                        <td>
                                            <div class="pull-right">
                                                <a href="@Url.Action("Edit", "GPS_DonViHanhChinh", new { id = item.DVHC_MA })">
                                                    <img src="@Url.Content("~/fonts/grid-edit-icon.png")" title="Sửa" />
                                                </a>
                                                <a href="@Url.Action("Delete", "GPS_DonViHanhChinh", new { id = item.DVHC_MA })">
                                                    <img src="@Url.Content("~/fonts/grid-delete-icon1.gif")" title="Hủy Hồ Sơ" />
                                                </a>
                                            </div>
                                        </td>
                                    </tr>
                                }
                            }
                        }
                    </table>
                </div>

                <div class="pagination-sm" style="clear:both; padding: 5px 0;">
                    @Html.PagedListPager(Model.SearchResults, page => Url.Action("Index", new
   {
       page,
       Model.dDVHC_MA,
       Model.dDVHC_TEN,
       Model.dDVHC_ACTIVE,
       Model.dDVHC_LOAI
   }))
                </div>
            </fieldset>
        </div>
    </div>
</div>


<!-- delete modal placeholder-->
<div id='deleteModal' class='modal fade in'>
    <div class="modal-dialog">
        <div class="modal-content">
            <div id='deleteModalContent'></div>
        </div>
    </div>
</div>

<!-- modal placeholder-->
<div id='myModal' class='modal fade in'>
    <div class="modal-dialog">
        <div class="modal-content">
            <div id='myModalContent'></div>
        </div>
    </div>
</div>

@section Scripts {
    @Scripts.Render("~/bundles/modalform")
}

